import superStyle from './style.js'

let attrs = {
  'size': 'font-size',
  'color': 'color',
  'type': 'font-weight',
  'text-overflow': 'text-overflow',
  'gravity': 'text-align',
  'maxLine': 'display: -webkit-box;-webkit-box-orient: vertical;overflow:hidden; text-overflow: ellipsis; -webkit-line-clamp'
}
export default {
  props: {
    size: String,
    selectedSize: String,
    color: String,
    selectedColor: String,
    // 粗体
    type: String,
    selectedType: String,
    maxLine: String,
    gravity: String

  },
  getTextStyle: (data) => {
    return superStyle.getStyle(data, (val, attrName) => {
      if (attrs[attrName]) {
        attrName = attrs[attrName]
      } else {
        // 没有注册的属性直接 过滤
        return ''
      }
      return {
        attrName,
        val
      }
    })
  }, getSelectTextStyle: (data) => {
    return superStyle.getStyle(data, (val, attrName) => {
      if (attrs[attrName]) {
        switch (attrName) {
          case 'color':
            val = data.selectedColor ? data.selectedColor : val
            break
          case 'size':
            val = data.selectedSize ? data.selectedSize : val
            break
          case 'type':
            val = data.selectedType ? data.selectedType : val
            break
        }
        attrName = attrs[attrName]
      } else {
        // 没有注册的属性直接 过滤
        return ''

      }
      return {
        attrName,
        val
      }
    })
  }, addAttr: (attrName, attrValue) => {
    attrs[attrName] = attrValue
  }

}
